<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var rotate = function () {
            let nums = [1, 2, 3, 4, 5, 6, 7]
            let k = 3
            let c=nums.length
            let a = nums.slice(-k)
            // let b = nums.slice(0, k + 1)
            nums.unshift(a)
            nums=a.concat()
            return nums
        };
        console.log(rotate());
    </script>
</body>

</html>